
<!DOCTYPE html>
<html>
<head>
<script charset="utf-8" src="js/jquery.min.js"></script>
<script charset="utf-8" src="js/global.js"></script>
<script charset="utf-8" src="js/bootstrap.min.js"></script>
<script charset="utf-8" src="js/template.js"></script>

<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/style.css?v=1">
<link rel="stylesheet" href="css/member.css">
<link rel="stylesheet" href="css/order3.css"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="yes" name="apple-touch-fullscreen">
<meta content="telephone=no" name="format-detection">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1;user-scalable=no;">
<script charset="utf-8" src="js/shopCart.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
<title>购物车</title>
</head>
<body>
<div class="fanhui_cou">
	<div class="fanhui_1"></div>
	<div class="fanhui_ding">顶部</div>
</div> <header class="header header_1">
    <div class="fix_nav">
        <div class="nav_inner">
            <a class="nav-left back-icon" href="javascript:history.back();">返回</a>
            <div class="tit">购物车</div>
        </div>
    </div>
</header>
<div class="container ">
    <div class="row rowcar">
        <ul class="list-group">
		            <li class="list-group-item hproduct clearfix">
			                <div class="p-pic"><a href="/views/663"><img class="img-responsive" render-src="product.coverUrl"></a></div>
			                <div class="p-info">
			                    <a href="/views/663"><p class="p-title" render-html="product.productName"></p></a>
		                    	<p class="p-attr">
			                    		颜色:<span render-html="color"></span>色<br/>
			                    		尺寸:<span render-html="size"></span>
                                </p>
		                    	<p class="p-origin">
			                    	<a class="close p-close" onclick="deleteShopCart('','艾吉贝2015新款多层收纳真皮单肩斜挎包女包头层牛皮斜跨小包包女','663','1358')" href="javascript:void(0);">×</a>
                                    原价:<em class="price">¥<span render-html="product.salePrice" style="text-decoration:line-through"></span></em><br/>
                                    现价:<em class="price">¥<span render-key="product.salePrice" render-fun="getPrice"></span></em>
			                    </p>
			                </div>
		            </li>
		            <li class="list-group-item clearfix">
		                <div class="pull-left mt5">
		                	<span class="gary">小计：</span>
		                	<em class="red productTotalPrice">¥<span class="totalPrice" render-key="product.salePrice" render-fun="getPrice"></span></em>
		                </div>
						<div class="btn-group btn-group-sm control-num">
		                    <a onclick="disDe(this)" href="javascript:void(0);" class="btn btn-default"><span class="glyphicon glyphicon-minus gary"></span></a>
		                    <input type="number" class="btn gary2 Amount" name="num" readonly render-key="num" render-fun="getTotalPrice"  itemkey="" prodId="663" skuId="1358">
		                    <a onclick="increase(this)" href="javascript:void(0);" class="btn btn-default"><span class="glyphicon glyphicon-plus gary"></span></a>
		                </div>
					</li>
					</ul>
		       </div>
</div>
<div class="fixed-foot">
<div class="fixed_inner">
    <div class="pay-point">
        <div class="icheck pull-left mr10">
            <input type="checkbox" checked="checked" id="buy-sele-all" value="1">
            <label for="buy-sele-all">
                <span class="mt10"></span>全选
            </label>
        </div>
         <p>合计：<em class="red f22">¥<span id="totalPrice"></span></em></p>
    </div>
    <div class="buy-btn-fix">
        <a data-href="/mine/pay.html?id=" class="btn btn-danger btn-buy">去结算</a>
    </div>
</div>
</div>
<div class="clear"></div>

<footer class="footer">
  <div class="foot-con">
	<div class="foot-con_2">
		<a href="index.html">
			<i class="navIcon home"></i>
			<span class="text">首页</span>
		</a>
		<a href="category.html">
			<i class="navIcon sort"></i>
			<span class="text">分类</span>
		</a>
		<a href="shopcart.html">
			<i class="navIcon shop"></i>
			<span class="text">购物车</span>		
		</a>
		<a href="userhome.html">
			<i class="navIcon member"></i>
			<span class="text">我的</span>
		</a>
	</div>
  </div>
</footer>
<script type="text/javascript">
	var totalPrice = 0;
	var json = JSON.parse(sessionStorage.getItem("json"));
    var num = json.product.storeNum;
    var user = JSON.parse(sessionStorage.getItem("user"));
    $(".list-group").renderValues(json,{
        getPrice:function(item,value){
            $(item).html(value * json.product.cutoff);
        },
        getTotalPrice:function(item,value){
			$(".totalPrice").html((json.product.salePrice * json.product.cutoff)*Number(value));
			$(item).val(value);
            price();
		}
    });

    function disDe(src){
       var storeNum = $("input[name='num']");
        if(storeNum.val() > 1){
            var temp = Number(storeNum.val()) - 1;
            storeNum.val(temp);
            $(".totalPrice").html(((json.product.salePrice * json.product.cutoff) * Number(temp)).toFixed(2));
            price();
        }
    }
    function increase(src){
        var storeNum = $("input[name='num']");
        if(storeNum.val() < num){
            var temp = Number(storeNum.val()) + 1;
            storeNum.val(temp);
            $(".totalPrice").html(((json.product.salePrice * json.product.cutoff) * Number(temp)).toFixed(2));
            price();
        }
    }


	function price(){
        totalPrice = 0;
		$.each($(".totalPrice"),function(index,ele){
			totalPrice += Number($(ele).text());
		});
        totalPrice = totalPrice.toFixed(2);
        $("#totalPrice").html(totalPrice);
	}

	$("#buy-sele-all").click(function(){
       if(this.checked){
           price();
       }else{
           $("#totalPrice").html("00.00");
	   }
    });

	$(".btn-buy").click(function(){
        if(user){
			var url = $(this).data("href");
            var myOrder = {
				"product.id":json.product.id,
				"user.id":user.id,
				"color":json.color,
				"number":$("input[name='num']").val(),
				"size":json.size,
				"state":1
			};

			$.post("/myOrders",myOrder,function(data){
                window.location.href = url + data;
			});
		}
	});




</script>
</body>
</html>
